package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.ParsedObjectBuilder;
import org.xx.armory.swing.components.TypedTableColumnType;

import java.util.ArrayList;
import java.util.List;

public class TableColumnModelBuilder
        extends ParsedObjectBuilder<TableColumnModel>
        implements OptionsContainerBuilder {
    private String name;
    private String title;
    private TypedTableColumnType type;
    private int size;
    private String optionsName;
    private List<OptionModel> options;

    public TableColumnModelBuilder() {
        this.options = new ArrayList<>();
    }

    public TableColumnModelBuilder setName(
            String name
    ) {
        this.name = name;
        return this;
    }

    public TableColumnModelBuilder setTitle(
            String title
    ) {
        this.title = title;
        return this;
    }

    public TableColumnModelBuilder setType(
            TypedTableColumnType type
    ) {
        this.type = type;
        return this;
    }

    public TableColumnModelBuilder setSize(
            int size
    ) {
        this.size = size;
        return this;
    }

    public TableColumnModelBuilder setOptionsName(
            String optionsName
    ) {
        this.optionsName = optionsName;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void addOption(
            OptionModel option
    ) {
        this.options.add(option);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public TableColumnModel build() {
        return new TableColumnModel(getLineInfo(), this.name, this.title, this.type, this.size, this.optionsName, this.options);
    }
}
